package com.gzy.cbrsystem.core;

import java.util.ArrayList;
import java.util.List;

import com.gzy.cbrsystem.core.insomnia.InsomniaCaseBase;
import com.gzy.cbrsystem.core.interfaces.Case;
import com.gzy.cbrsystem.core.interfaces.CaseBasic;
import com.gzy.cbrsystem.core.interfaces.ReasoningMethod;
import com.gzy.cbrsystem.core.interfaces.SimilarityCalculation;

public class NearestNeighborMethod implements ReasoningMethod{

	public List<ReasoningResult> calculateSimilarity(
			CaseBasic query, InsomniaCaseBase caseBase,
			SimilarityCalculation insomniaSimilarity) {
		
		List<ReasoningResult> reResults=new ArrayList<ReasoningResult>();
		for(Case c:caseBase.getCases())
		{
			ReasoningResult r=new ReasoningResult();
			r.setCase(c);
			double sim = insomniaSimilarity.CalculateSimilarity(query, c.getCaseDescription());
			r.setSimilarity(sim);
			reResults.add(r);
		}
		return reResults;
	}
}
